//
//  LSRightCell.m
//  LookScore
//
//  Created by wws on 2018/3/21.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSRightCell.h"
#import "LSExponentModel.h"
@interface LSRightCell ()

//@property (nonatomic, strong) UILabel * timeLabel;
@property (nonatomic, strong) UILabel * hostWinLabel;
@property (nonatomic, strong) UILabel * concedePointsLabel;
@property (nonatomic, strong) UILabel * guestWinLabel;

@end

@implementation LSRightCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (LSRightCell *)RightTableViewCellBytableView:(UITableView *)tableView{
    LSRightCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSRightCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addSubviewToContenView];
    }
    return self;
}

- (void)addSubviewToContenView{
    //时间
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.text = @"11-20\n10:50";
    _timeLabel.font = LSFontSize10;
    _timeLabel.numberOfLines = 0;
    _timeLabel.textColor = LSTitleGrayColor2;
    _timeLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_timeLabel];
    _timeLabel.sd_layout.topEqualToView(0).leftEqualToView(0).heightRatioToView(self.contentView, 1).widthRatioToView(self.contentView, 0.25);
    
    //主胜
    _hostWinLabel = [[UILabel alloc] init];
    _hostWinLabel.text = @"1.26";
    _hostWinLabel.textAlignment = NSTextAlignmentCenter;
    _hostWinLabel.font = LSFontSize12;
    _hostWinLabel.textColor = LSTitleGrayColor2;
    [self.contentView addSubview:_hostWinLabel];
    
    _hostWinLabel.sd_layout.topEqualToView(0).leftSpaceToView(_timeLabel, 0 ).heightRatioToView(self.contentView, 1).widthRatioToView(self.contentView, 0.25);
    
    //让球
    _concedePointsLabel = [[UILabel alloc] init];
    _concedePointsLabel.text = @"半球";
    _concedePointsLabel.textAlignment = NSTextAlignmentCenter;
    _concedePointsLabel.font = LSFontSize12;
    _concedePointsLabel.textColor = LSTitleGrayColor2;
    [self.contentView addSubview:_concedePointsLabel];
    _concedePointsLabel.sd_layout.topEqualToView(0).leftSpaceToView(_hostWinLabel, 0).widthRatioToView(self.contentView, 0.25).heightRatioToView(self.contentView, 1);
    _guestWinLabel = [[UILabel alloc] init];
    _guestWinLabel.textAlignment = NSTextAlignmentCenter;
    _guestWinLabel.font = LSFontSize12;
    _guestWinLabel.text = @"1.02";
    _guestWinLabel.textColor = LSTitleGrayColor2;
    [self.contentView addSubview:_guestWinLabel];
    _guestWinLabel.sd_layout.topEqualToView(0).leftSpaceToView(_concedePointsLabel, 0).heightRatioToView(self.contentView, 1).widthRatioToView(self.contentView, 0.25);
    
    
}
- (void)setType:(NSInteger)type{
    
    _type = type;
    
}

- (void)setTmpModel:(companyData *)tmpModel{
    
    _tmpModel = tmpModel;
    if (self.type == 0) {
        if (_tmpModel.Odds_Win.floatValue < self.model.Odds_Win.floatValue) {
            _hostWinLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.Odds_Win.floatValue > self.model.Odds_Win.floatValue){
            _hostWinLabel.textColor = LSSubColorf25e59;
        }else{
            _hostWinLabel.textColor = LSTitleGrayColor2;
        }
        
        if (_tmpModel.Odds_Flat.floatValue < self.model.Odds_Flat.floatValue) {
            _concedePointsLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.Odds_Flat.floatValue > self.model.Odds_Flat.floatValue){
            _concedePointsLabel.textColor = LSSubColorf25e59;
        }else{
            _concedePointsLabel.textColor = LSTitleGrayColor2;
        }
        
        if (_tmpModel.Odds_Negative.floatValue < self.model.Odds_Negative.floatValue) {
            _guestWinLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.Odds_Negative.floatValue > self.model.Odds_Negative.floatValue){
            _guestWinLabel.textColor = LSSubColorf25e59;
        }else{
            _guestWinLabel.textColor = LSTitleGrayColor2;
        }
    }else if (self.type == 1){
        if (_tmpModel.HD_ZD.floatValue < self.model.HD_ZD.floatValue) {
            
            _hostWinLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.HD_ZD.floatValue > self.model.HD_ZD.floatValue){
            
            _hostWinLabel.textColor = LSSubColorf25e59;
        }else{
            _hostWinLabel.textColor = LSTitleGrayColor2;
        }
        
        if (_tmpModel.HD_PK.floatValue < self.model.HD_PK.floatValue) {
            
            _concedePointsLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.HD_PK.floatValue > self.model.HD_PK.floatValue){
            
            _concedePointsLabel.textColor = LSSubColorf25e59;
        }else{
            
            _concedePointsLabel.textColor = LSTitleGrayColor2;
        }
        
        if (_tmpModel.HD_KD.floatValue < self.model.HD_KD.floatValue) {
            _guestWinLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.HD_KD.floatValue > self.model.HD_KD.floatValue){
            _guestWinLabel.textColor = LSSubColorf25e59;
        }else{
            _guestWinLabel.textColor = LSTitleGrayColor2;
        }
        
    }else{
        if (_tmpModel.HD_DQ.floatValue < self.model.HD_DQ.floatValue) {
            _hostWinLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.HD_DQ.floatValue > self.model.HD_DQ.floatValue){
            _hostWinLabel.textColor = LSSubColorf25e59;
        }else{
            _hostWinLabel.textColor = LSTitleGrayColor2;
        }
        
        if (_tmpModel.HD_PK.floatValue < self.model.HD_PK.floatValue) {
            _concedePointsLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.HD_PK.floatValue > self.model.HD_PK.floatValue){
            _concedePointsLabel.textColor = LSSubColorf25e59;
        }else{
            _concedePointsLabel.textColor = LSTitleGrayColor2;
        }
        
        if (_tmpModel.HD_XQ.floatValue < self.model.HD_XQ.floatValue) {
            _guestWinLabel.textColor = LSSubColor9dd3cc;
        }else if (_tmpModel.HD_XQ.floatValue > self.model.HD_XQ.floatValue){
            _guestWinLabel.textColor = LSSubColorf25e59;
        }else{
            _guestWinLabel.textColor = LSTitleGrayColor2;
        }
    }
    
    
}

- (void)setModel:(companyData *)model{
    
    _model = model;
    
    self.timeLabel.text = [model.ChangeTime stringByReplacingOccurrencesOfString:@" " withString:@"\n"];
    
    
    if (self.type == 0) {
        self.hostWinLabel.text = model.Odds_Win;
        
        self.guestWinLabel.text = model.Odds_Negative;
        
        self.concedePointsLabel.text = model.Odds_Flat;
    }else if (self.type ==1){
        self.hostWinLabel.text = model.HD_ZD;
        
        self.guestWinLabel.text = model.HD_KD;
        
        self.concedePointsLabel.text = model.HD_PK;
        
    }else{
        
        self.hostWinLabel.text = model.HD_DQ;
        
        self.guestWinLabel.text = model.HD_XQ;
        
        self.concedePointsLabel.text = model.HD_PK;
    }
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
